#!/usr/bin/php -c/etc/gtk/php.ini
<?php

/*//. Operating System Reporter
  ../ Bob Majdak Jr <bob@kateos.org>
  ../ http://phpgtk.opsat.net .//*/

define('THE_STRING_FMT',"<span size='x-large' weight='bold'>Hello There.</span>\nYour Operating System Is...\n\t%s");

if(strtolower(substr(PHP_OS,0,3)) == 'win') {
	//. windows...
	define('THE_STRING',sprintf(
		THE_STRING_FMT,
		trim(shell_exec('ver'))
	));
} else {
	if(trim(shell_exec('which uname'))) {
		//. linux bsd solaris...
		define('THE_STRING',sprintf(
			THE_STRING_FMT,
			trim(shell_exec('uname -sr'))
		));
	}
	
	else {
		//. ...
		define('THE_STRING',sprintf(
			THE_STRING_FMT,
			'... something. I have no idea.'
		));	
	}
}

class bobWindow extends GtkWindow {

	public $vbox;
	public $label,$button;
	
	public function __construct() {
		parent::__construct();

		$this->vbox = new GtkVBox;
		$this->button = new GtkButton('Close');
		$this->label = new GtkLabel;
		$this->label->set_markup(THE_STRING);
		
		$this->set_size_request(300,200);
		$this->set_title('Hello There');
		$this->set_position(Gtk::WIN_POS_CENTER);
		$this->connect_simple('delete-event',array($this,'on_quit'));
		
		$this->button->connect_simple('clicked',array($this,'on_quit'));

		$this->vbox->pack_start($this->label,true,true,3);
		$this->vbox->pack_start($this->button,false,true,0);
		$this->add($this->vbox);
		$this->show_all();
		return;
	}
	
	public function on_quit() {
		$this->hide();
		Gtk::main_quit();
		return;
	}
}

$window = new bobWindow;

Gtk::main();

$window->destroy();
unset($window);

?>